package com.jhws.business.comm.bo;

import com.jhws.business.comm.service.ITblCommDimService;
import com.jhws.core.dataUpdate.bo.DataUpdateObject;
import com.jhws.core.dataUpdate.bo.IDataUpdateModule;
import com.jhws.core.dataUpdate.service.DataUpdateService;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Component
public class CommUpdateData implements IDataUpdateModule {
    public static final String COMM_INFO = "comminfo";
    private String [] name = {COMM_INFO};
    @Resource
    DataUpdateService dataUpdateService;
    @Resource
    ITblCommDimService ICommService;

    @Override
    public String[] getModuleName() {
        return name;
    }

    @Override
    public DataUpdateObject getUserModuleData(String username, String ownerCode, Long timeStamp, String module, Map<String, String> moduleParams) throws Exception {
        return null;
    }

    @Override
    public DataUpdateObject getLabelModuleData(String label, Long timeStamp, String module, Map<String, String> moduleParams) throws Exception {
        List list = ICommService.findTblCommDimByWhere("where comm_code = '"+label+"'");
        return new DataUpdateObject(list);
    }

    @Override
    @PostConstruct
    public void registerModule() {
        dataUpdateService.registerModule(this);
    }
}
